/**
 * @file createColorField
 * @author fanxueliang@qq.com
 */
import type {ColorSpecItem, ColorPickerField} from '../interface';
import {getBasicField} from '../util';

export function createColorField(spec: ColorSpecItem, showIndex: number, path: string) {
    const component = 'Color';
    const basicField = getBasicField(spec, path, showIndex);
    const {presetColors = [], allowCustom} = spec?.extraAttr?.colorConfig || {}; // 防空
    return {
        ...basicField,
        type: 'COLOR',
        isLeaf: true,
        spec,
        component,
        presetColors,
        allowCustom
    } as ColorPickerField;
}
